# coding=utf-8

import base64
import requests

'''
人脸检测与属性分析
'''

s = None
with open("xx.jpg", 'rb') as f:
    b = base64.b64encode(f.read())
    s = b.decode()

request_url = "https://aip.baidubce.com/rest/2.0/face/v3/detect"

params = "{\"image\":\"" + s +"\",\"image_type\":\"BASE64\",\"face_field\":\"age,gender,face_type\"}"
access_token = '24.ebb57b5eeb8bd68404afcaf1813ecec4.2592000.1622166362.282335-24071481'
request_url = request_url + "?access_token=" + access_token
headers = {'content-type': 'application/json'}
response = requests.post(request_url, data=params, headers=headers)
if response:
    print (response.json())

